package cn.scw.project.system.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.system.domain.vo.SysUserExpendVo;
import cn.scw.project.system.service.ISysUserExpendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户消费记录Controller
 *
 * @author api
 * @date 2020-05-20
 */
@Api(tags = "用户消费记录")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH+"/system/expend")
public class SysUserExpendController extends BaseController {
    @Autowired
    private ISysUserExpendService sysUserExpendService;

    /**
     * 查询用户消费记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:expend:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam @ApiParam("类型（押金，充值，续租）") String type) {
        startPage();
        List<SysUserExpendVo> list = sysUserExpendService.selectSysUserExpendList(type);
        return getDataTable(list);
    }

    /**
     * 获取用户消费记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:expend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysUserExpendService.selectSysUserExpendVoById(id));
    }

//    /**
//     * 新增用户消费记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:expend:add')")
//    @Log(title = "用户消费记录", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody SysUserExpend sysUserExpend) {
//        return toAjax(sysUserExpendService.insertSysUserExpend(sysUserExpend));
//    }
//
//    /**
//     * 修改用户消费记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:expend:edit')")
//    @Log(title = "用户消费记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody SysUserExpend sysUserExpend) {
//        return toAjax(sysUserExpendService.updateSysUserExpend(sysUserExpend));
//    }
//
//    /**
//     * 删除用户消费记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:expend:remove')")
//    @Log(title = "用户消费记录", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return toAjax(sysUserExpendService.deleteSysUserExpendByIds(ids));
//    }
}
